<div [@routerTransition] (click)="clickContainer()">
    <div class="content d-flex flex-column flex-column-fluid">

        <sub-header [title]="'SalesInfo' | localize" [description]="'SalesInfo' | localize">
            <div role="actions">
            </div>
        </sub-header>

        <div [class]="containerClass">
            <div class="card card-custom gutter-b">
                <div class="card-body">
                    <tabset class="tab-container tabbable-line">
                        <tab class="pt-5" heading="{{l('SkuMsg')}}" customClass="m-tabs__item icon-dingdan1"
                            (selectTab)="changePage()">
                        </tab>
                        <tab class="pt-5" heading="{{l('MemberMsg')}}" customClass="m-tabs__item icon-huiyuanguanli" active="true">
                            <div class="row">
                                <form class="horizontal-form" autocomplete="off">
                                    <div class="m-form m-form--label-align-right">
                                        <div class="row align-items-center m--margin-bottom-10">
                                            <div class="col-3">
                                                <div class="form-group m-form__group align-items-center">
                                                    <label>{{l('name')}}</label>
                                                    <div class="input-group">
                                                        <input [(ngModel)]="filterText" name="filterText" autoFocus
                                                            class="form-control m-input" (keyup.enter)="getSalesInfo()"
                                                            [placeholder]="l('SearchWithThreeDot')" type="text">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-3" style="position:relative;">
                                                <div class="form-group m-form__group align-items-center">
                                                    <label>{{l('startEndTime')}}</label>
                                                    <date-range-picker needInitDate="true" name="SampleDateRangePicker"
                                                        [showButton]="false" (buttonEmit)="getSalesInfo()"
                                                        [(startDate)]="startTime" [(endDate)]="endTime"
                                                        [allowFutureDate]="false">
                                                    </date-range-picker>
                                                </div>
                                            </div>
                                            <div class="col-2">
                                                <label>{{l('membershipType')}}</label>
                                                <div class="form-group" style="margin-bottom:0;">
                                                    <div class="input-group">
                                                        <select class="form-control" [(ngModel)]="memberShipType"
                                                            name="memberShipType">
                                                            <option value="">{{l('All')}}</option>
                                                            <option [value]="memberType.value"
                                                                *ngFor="let memberType of memberTypes">
                                                                {{memberType.name}}</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                            <!-- <div class="col-2">
                                                <label>{{l('belongStore')}}</label>
                                                <div class="form-group" style="margin-bottom:0;">
                                                    <div class="input-group">
                                                        <select #StoreCombobox class="form-control"
                                                            [(ngModel)]="belongStore" name="belongStore"
                                                            [attr.data-live-search]="true" jq-plugin="selectpicker">
                                                            <option value="">{{l('All')}}</option>
                                                            <option [value]="store.storeId"
                                                                *ngFor="let store of stores">{{store.displayName}}
                                                            </option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div> -->
                                            <div class="col-2" style="position:relative;padding-bottom: 0;top:-0.4rem;">
                                                <app-high-tree #highTree
                                                    [selfConfig]="{labelName:l('belongStore'),searchDepth:'store'}"
                                                    [config]="{singleSelect:true,canOnlyChooseType:'store'}"
                                                    (onTreeUpdate)="onTreeUpdate($event)">
                                                </app-high-tree>
                                            </div>

                                            <div class="col-2 text-right">
                                                <div class="form-group m-form__group align-items-center">
                                                    <label style="display: block;">&nbsp;</label>
                                                    <button type="button" class="btn btn-primary"
                                                        [buttonBusy]="primengTableHelper.isLoading"
                                                        (click)="getSalesInfo()">
                                                        <i class="la la-refresh"></i>
                                                        {{l("search")}}
                                                    </button>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="row align-items-center">
                                <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                                    <p-table #dataTable (onLazyLoad)="getSalesInfo($event)"
                                        [value]="primengTableHelper.records"
                                        [rows]="primengTableHelper.defaultRecordsCountPerPage" [paginator]="false"
                                        [lazy]="true" [resizableColumns]="primengTableHelper.resizableColumns"
                                        [responsive]="primengTableHelper.isResponsive">
                                        <ng-template pTemplate="header">
                                            <tr>
                                                <th style="width: 15%">{{l('Actions')}}</th>
                                                <th style="width:5%">{{l('RecordId')}}</th>
                                                <th pSortableColumn="amount">
                                                    {{l('TotalSales')}}
                                                    <p-sortIcon field="amount"></p-sortIcon>
                                                </th>
                                                <th>{{l('memberNo')}}</th>
                                                <th pSortableColumn="registerdTime">
                                                    {{l('registerDay')}}
                                                    <p-sortIcon field="registerdTime"></p-sortIcon>
                                                </th>
                                                <th pSortableColumn="type">
                                                    {{l('membershipType')}}
                                                    <p-sortIcon field="type"></p-sortIcon>
                                                </th>
                                                <th>
                                                    {{l('wechatNick')}}
                                                </th>
                                                <th>
                                                    {{l('name')}}
                                                </th>
                                                <th>
                                                    {{l('gender')}}
                                                </th>
                                                <th>
                                                    {{l('registerPhoneNumber')}}
                                                </th>
                                                <th>
                                                    {{l('belongStore')}}
                                                </th>

                                            </tr>
                                        </ng-template>
                                        <ng-template pTemplate="body" let-record let-i="rowIndex">
                                            <tr [pSelectableRow]="record" [attr.trid]="record.id">
                                                <td>
                                                    <div class="btn-group dropdown" normalizePosition>
                                                        <button class="btn btn-sm btn-primary"
                                                            (click)="showDetail(record)">
                                                            {{l("detail")}}
                                                        </button>
                                                    </div>
                                                </td>
                                                <td style="width:5%"> {{transIndex(i)}}</td>
                                                <td>
                                                    <span>{{record.amount|currency:'￥'}}</span>
                                                </td>
                                                <td>
                                                    <span>
                                                        {{record.memberNo}}
                                                    </span>
                                                </td>
                                                <td>
                                                    <span>
                                                        {{record.registerdTime| date : "yyyy/MM/dd"}}
                                                    </span>
                                                </td>
                                                <td>
                                                    <span>
                                                        {{record.type}}
                                                    </span>
                                                </td>
                                                <td>
                                                    <span>
                                                        {{record.snsNickName}}
                                                    </span>
                                                </td>
                                                <td>
                                                    <span>
                                                        {{record.name}}
                                                    </span>
                                                </td>
                                                <td>
                                                    <span>
                                                        {{record.gender}}
                                                    </span>
                                                </td>
                                                <td>
                                                    <span>{{record.regPhone}}</span>
                                                </td>
                                                <td>
                                                    <span>{{record.storeName}}</span>
                                                </td>
                                            </tr>
                                        </ng-template>
                                        <ng-template pTemplate="emptymessage" let-records>
                                            <tr *ngIf="primengTableHelper.records">
                                                <td colspan="11">
                                                    <img class="emptymessage"
                                                        src="/assets/common/images/placeholder/deviceHolder.png" />
                                                </td>
                                            </tr>
                                        </ng-template>
                                    </p-table>
                                    <div class="primeng-paging-container">
                                        <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                            (onPageChange)="getSalesInfo($event)"
                                            [totalRecords]="primengTableHelper.totalRecordsCount"
                                            [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
                                        </p-paginator>
                                        <span class="total-records-count">
                                            {{l('TotalRecordsCount', primengTableHelper.totalRecordsCount)}}
                                        </span>
                                    </div>
                                </div>
                                <!--<Primeng-Datatable-End>-->
                            </div>
                        </tab>
                    </tabset>
                </div>
            </div>
        </div>

        <memberInfoModal #MemberInfoModalComponent (modalSave)="getSalesInfo()"></memberInfoModal>
    </div>

</div>